class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:
        
        if len(strs) == 0:
            return ""
        str_ = strs[0]

        for s in strs[1:]:
            str_ = self.check2strings(str_, s)

        return str_

    def check2strings(self, str1, str2):
            length = min(len(str1), len(str2))

            if length == 0:
                common = ""
            else:
                for i in range(length):
                    if str1[i] == str2[i]:
                        common = str1[:i+1]
                    else:
                        common = str1[:i]
                        break
            return common
            
"""
在比较字符串时，注意：
"c" 和 "c"，单个相同的字符会漏掉，同下；
"flow" 和 "flow"，字符一样的使用str_[:i]有可能漏掉最后一个字符；

此外，当单个字符str1[i]与str2[i]不一样时，需要break。
"""